import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class PathCache {
	private static Map<String, StaticMethod> cacheMap = new HashMap<String, StaticMethod>();
	
	public static void cacheMethod(String className, String methodSig, StaticMethod method){
		String cacheKey = className + "::" + methodSig;
		StaticMethod existingMethod = cacheMap.get(cacheKey);
		
		if(existingMethod == null){
			StaticMethod cacheMethod = new StaticMethod();
			cacheMethod.setMethodSignature(method.getMethodSignature());
			List<StaticPath> pathsInMethod = new ArrayList<StaticPath>(method.getPaths());
			cacheMethod.setPaths(pathsInMethod);
			
			cacheMap.put(cacheKey, cacheMethod);
		}
	}
	
	public static StaticMethod findMethod(String className, String methodSig){
		return cacheMap.get(className + "::" + methodSig);
	}
}
